import 'package:dio/dio.dart';
// import 'package:flutter_getuuid/flutter_getuuid.dart';
import 'package:shared_preferences/shared_preferences.dart';

class TokenInterceptor extends Interceptor {
  @override
  onRequest(RequestOptions options) async {
    /// 在发送请求之前做一些预处理
    SharedPreferences prefs = await SharedPreferences.getInstance();

    // String sessionToken;

    // String userticket = prefs.getString('userticket');
    options.headers['Content-Type'] = 'application/json;charset=UTF-8';

    // sessionToken = prefs.getString('token');
    // String jws = prefs.getString('jws');
    // options.headers["Content-Encoding"] = "gzip";
    options.headers['Amway-Ada'] = prefs.getString('Amway-Ada');
    options.headers['Amway-Id'] = prefs.getString('Amway-Id');
    // options.headers['Token'] = sessionToken;
    // options.headers['JWS'] = jws;
    // options.headers['User-Ticket'] = userticket;
    // options.headers['Device-id'] = await FlutterGetuuid.platformUid;
    // LogsUtil.i('请求的设备id是', options.headers['Device-id']);
    // LogsUtil.i('Amway-Ada', prefs.getString('Amway-Ada'));
    // LogsUtil.i('Amway-Id', prefs.getString('Amway-Id'));

    return options;
  }

  @override
  onResponse(Response response) async {
    return response;
  }

  @override
  onError(DioError error) async {
    super.onError(error);
  }
}